<?php


namespace app\api\controller\xiluedu;


use app\common\controller\Api;
use app\common\model\xiluedu\CourseFree AS CourseFreeModel;
use app\common\model\xiluedu\CourseFreeEnroll;
use think\Exception;

class CourseFree extends Api
{

    protected $noNeedRight=['*'];

    protected $noNeedLogin = ['course_free'];

    /**
     * 获取最近的
     */
    public function course_free(){
        $lists = CourseFreeModel::getCourseFree($this->auth->id);
        $this->success('查询成功',$lists);
    }

    /**
     * 预约免费课程活动
     */
    public function course_free_enroll(){
        $course_free_id = $this->request->param('course_free_id');
        try {
            $row = CourseFreeEnroll::addCourseFreeEnroll($course_free_id,$this->auth->id);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }

        $this->success('预约成功',$row);
    }

}